﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        WebClient webClient = new WebClient();
        webClient.Headers["Accept"] = "application/json";
        webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadCatalogCompleted);
        webClient.DownloadStringAsync(new Uri("http://localhost:8492/api/Mahasiswa"));

    }

    private void webClient_DownloadCatalogCompleted(object sender, DownloadStringCompletedEventArgs e)
    {
        this.Items.Clear();
        if (e.Result != null)
        {
            Label1.Text = e.Result.Substring(1, e.Result.Count() - 2);
            //string[] data = JsonConvert.DeserializeObject<string[]>(e.Result);
            DataMahasiswa data = JsonConvert.DeserializeObject<DataMahasiswa>(e.Result);
            //GridView_Main.DataSource = mhs;
            //GridView_Main.DataBind();
        }
    }


}

public class DataMahasiswa
{
    public string NIM { set; get; }
    public string Nama { set; get; }
    public int Umur { set; get; }
    public string Alamat { set; get; }
    public string Jurusan { set; get; }
}